package com.rao.crm.service.impl;

import com.rao.crm.dao.UserDao;
import com.rao.crm.dao.impl.BaseDaoImpl;
import com.rao.crm.domain.User;
import com.rao.crm.service.UserService;
import com.rao.crm.utils.MD5Utils;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Srao
 * @version 1.0
 * @className UserServiceImpl
 * @date 2019/9/18 19:30
 * @package com.rao.crm.service.impl
 * @description
 */
@Transactional
public class UserServiceImpl implements UserService {

    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public void regist(User user) {
        user.setUser_password(MD5Utils.md5(user.getUser_password()));
        user.setUser_state("1");
        userDao.regist(user);
    }

    @Override
    public User login(User user) {
        user.setUser_password(MD5Utils.md5(user.getUser_password()));
        return userDao.login(user);
    }

    @Override
    public List<User> findAll() {
        return userDao.findAll();
    }

    @Override
    public void update(User existUser) {
        userDao.update(existUser);
    }

    @Override
    public User findById(Long user_id) {
        return userDao.findById(user_id);
    }
}
